package com.pan.admin.module.api.controller;

import com.pan.admin.common.core.controller.BaseController;
import com.pan.admin.common.core.domain.AjaxResult;
import com.pan.admin.common.core.page.TableDataInfo;
import com.pan.admin.module.api.entity.po.ApiKeyBillPO;
import com.pan.admin.module.api.entity.qo.ApiKeyBillQO;
import com.pan.admin.module.api.service.ApiKeyBillService;
import com.pan.admin.module.api.service.ApiKeyService;
import com.pan.admin.module.loanProduct.service.LoanProductPlanService;
import com.pan.admin.module.loanProduct.service.LoanProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 渠道充值记录
 *
 * @author caoxin
 */
@RestController
public class ApiKeyBillController extends BaseController {

    @Autowired
    private ApiKeyBillService apiKeyBillService;
    @Autowired
    private ApiKeyService apiKeyService;
    @Autowired
    private LoanProductService loanProductService;
    @Autowired
    private LoanProductPlanService loanProductPlanService;

    /**
     * api渠道
     */
    @GetMapping("/api/apiKeyBill/listApiKey")
    @PreAuthorize("@ss.hasPermi('api:apiKeyBill:list')")
    public AjaxResult listApiKey(@RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.apiKeyService.listApiKey(keyword));
    }

    /**
     * 主体
     */
    @GetMapping("/api/apiKeyBill/listLoanProduct")
    @PreAuthorize("@ss.hasPermi('api:apiKeyBill:list')")
    public AjaxResult listLoanProduct(@RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanProductService.listLoanProduct(keyword));
    }

    /**
     * 计划
     */
    @GetMapping("/api/apiKeyBill/listLoanProductPlan")
    @PreAuthorize("@ss.hasPermi('api:apiKeyBill:list')")
    public AjaxResult listLoanProductPlan(@RequestParam(required = false) List<Long> loanProductId, @RequestParam(required = false) String keyword) {
        return AjaxResult.success(this.loanProductPlanService.listLoanProductPlan(loanProductId, keyword));
    }

    /**
     * 查询渠道充值记录列表
     */
    @GetMapping("/api/apiKeyBill/list")
    @PreAuthorize("@ss.hasPermi('api:apiKeyBill:list')")
    public TableDataInfo list(ApiKeyBillQO apiKeyBillQO) {
        startPage();
        List<ApiKeyBillPO> list = this.apiKeyBillService.list(apiKeyBillQO);
        return getDataTable(list);
    }

}
